package com.wn.bean;

public class Result<T> {
    // 返回的状态码：200成功； 500失败
    private Integer code;
    // 返回的提示内容
    private String msg;
    // 返回的数据
    private T obj;

    // 操作成功
    public static <T> Result<T> ok() {
        return new Result<>(200,"操作成功!",null);
    }
    public static <T> Result<T> ok(T obj) {
        return new Result<>(200,"操作成功!",obj);
    }

    // 操作失败
    public static <T> Result<T> fail() {
        return new Result<>(500,"操作失败!",null);
    }
    public static <T> Result<T> fail(String msg) {
        return new Result<>(500,msg,null);
    }

    public Result() {
    }

    public Result(Integer code, String msg, T obj) {
        this.code = code;
        this.msg = msg;
        this.obj = obj;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getObj() {
        return obj;
    }

    public void setObj(T obj) {
        this.obj = obj;
    }
}